
// rename to helper
var Html5Test = {}
Html5Test.testCaseList = [];
var lastrand = 31029;

Html5Test.StartupParameter = {
	width: 		0,
	height: 	0,
	fps: 		30,
	cascade: 	true,
	tags:		null,
	canvas: 	null,
}

Html5Test.System_Initiate = function() {
	var param = Html5Test.StartupParameter;
	for (var p in param) {
		if (param[p] === null) {
			return null;
		}
	}
	window.Html5Test._core = new Html5Test.Core(param);
	return window.Html5Test._core;
}

Html5Test.System_SetState = function(state, value) {
	if (Html5Test.StartupParameter[state] !== undefined) {
		Html5Test.StartupParameter[state] = value;
		return true;
	}
	return false;
}

Html5Test.System_Start = function() {
	this._core.start();
}


Html5Test.Core = function(param) {
	//basic configuration
	this.canvas = param.canvas;
	this.canvas.width = param.width;
	this.canvas.height = param.height;
	this.fps = param.fps;
	this.cycle = 1000 / this.fps;
	this.ctx = this.canvas.getContext('2d');

	for (var i = 0; i < Html5Test.testCaseList.length; i++) {
		Html5Test.LoadTestManager.addCase(Html5Test.testCaseList[i]);
	}

	Html5Test.LoadTestManager.initializeTags(param.tags);

	// test suite list
	this.start = function() {
		Html5Test.LoadTestManager.cascadeTest();
	}

	this.clearUp = function() {
		ctx.clearRect(0, 0, this.canvas.width, this.canvas.height);
	}
}


function randint(minn, maxn) {
	var d = lastrand / 32749;
	lastrand = (25903 * lastrand + 19997) % 32749;
	return parseInt(minn + d * (maxn - minn + 1));
}

